<style lang="less">
  .tips-list {
    .ivu-modal-body {
      overflow: hidden;
    }
  }
</style>

<template>
  <Modal v-model='status'
         footer-hide
         title="所属河流的举报"
         width="1000"
         class="tips-list">
    <Table :data="list"
           :columns="columns"
           stripe
           max-height="560"></Table>
    <Page class="pull-right"
          :total="Page.total"
          :current="Page.current"
          :page-size="Page.pageSize"
          size="small"
          show-total
          @on-change="changePage"></Page>
    <Spin v-show="loading"
          size="large"
          fix>
      <Icon type="ios-loading"
            size=18
            class="demo-spin-icon-load"></Icon>
      <div>加载中...</div>
    </Spin>
  </Modal>
</template>

<script>
import { reqPost } from 'global/axios';

export default {
  data() {
    return {
      status: false,
      loading: false,
      Page: {
        current: 1,
        pageSize: 10,
        total: 0,
      },
      columns: [
        {
          title: '地址',
          key: 'address',
          width: 90,
        },
        {
          title: '投诉来源',
          key: 'user_type_name',
          width: 90,
        },
        {
          title: '状态',
          key: 'solve_is',
          width: 90,
        },
        {
          title: '河名',
          width: 90,
          key: 'river_name',
        },
        {
          title: '时间',
          key: 'report_time',
          width: 150,
        },
        {
          title: '计划时间',
          key: 'plan_time',
          width: 100,
        },
        {
          title: '描述',
          key: 'overview',
        },
      ],
      list: [],
    };
  },

  methods: {
    async show(page = 1) {
      this.status = true;
      this.loading = true;
      let res = await reqPost({
        data: {
          solve_is: '已结束|#|ne',
          order: { report_time: -1 },
          page: page,
          pageSize: this.Page.pageSize
        },
        url: '/emergency/report/myriverrep',
      });

      if (res && res.code === '0000') {
        this.list = res.result.result.map(item => {
          switch (item.user_type) {
            case '1':
              item.user_type_name = '微信投诉';
              break;
            case '2':
              item.user_type_name = '河长巡查';
              break;
            case '3':
              item.user_type_name = '电话投诉';
              break;
            case '4':
              item.user_type_name = '信访投诉';
              break;
          }
          return item;
        });
        this.Page.total = res.result.totalSize;
      }
      this.loading = false;
    },
    changePage(page) {
      this.show(page);
    },
  },
};
</script>

<style>
</style>